/**
 * @description  客户管理参数
 */

const Customers = (mongoose) => {
  const { Schema, model } = mongoose

  // 客户管理参数
  const params = {
    customerId: {
      unique: true,
      type: String,
    },
    customerName: {
      type: String,
      required: true,
    },
    customerPhone: {
      type: String,
      trim: true,
    },
    customeAddress: {
      type: String,
    },
    phoneRegex: {
      type: String,
    },
    remarks: {
      type: String,
    },
    isContact: {
      type: Boolean,
      default: false,
    },
    registrant: {
      type: String,
    },
    creator: {
      type: String,
    },
    creatorNo: {
      type: Number,
    },
    tags: {
      type: String,
      default: 'VIP',
    },

    deleted: {
      type: Boolean,
      default: false,
    },
    deletedTime: {
      type: Date,
    },
    deleter: {
      type: String,
    },
  }

  const customerSchema = new Schema(params, {
    timestamps: {
      createdAt: 'createTime',
      updatedAt: 'updateTime',
    },
  })

  return model('admin_customer_manage', customerSchema)
}

module.exports = Customers
